<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="resources/css/style.css" type="text/css"/>

<style type="text/css">
.zipT td {
	border: 1px solid #bbbbbb;
}
</style>

<script src="resources/js/jquery-1.9.1.js"></script>
<script type="text/javascript">
function selectDong() {
	var index = $("input[name=zip]:checked").val();
	var zip = $("#zip_"+index).html();
	var address_1 = $("#address_"+index).html();
	
	if(zip == null || zip == "") {
		alert("우편번호를 선택하세요");
		return;
	}
	
	$("input[name=zip]", opener.document).val(zip);
	$("input[name=address_1]", opener.document).val(address_1);
	self.close();
}
</script>

<title>꽁알 : Administrator</title>
</head>
<body>

<c:if test="${fn:length(zipList) > 0 }">
<table class="zipT" width="100%" align="center" cellpadding="2" cellspacing="0" style="border:1px solid #666666;">
	<tr class="table_title">
		<td width="10%">선택</td>
		<td width="20%">우편번호</td>
		<td>주소</td>
	</tr>
</table>
<div style="height:300px;overflow:auto;">
<table class="zipT" width="100%" align="center" cellpadding="2" cellspacing="0" style="border:1px solid #666666;">
	<c:forEach var="list" items="${zipList }" varStatus="stat">
		<tr>
			<td width="10%"><input type="radio" name="zip" value="${stat.index }"/></td>
			<td width="20%" id="zip_${stat.index }">${list.zipcode }</td>
			<td id="address_${stat.index }">${list.sido } ${list.gugun } ${list.dong } ${list.bunji }</td>
		</tr>
	</c:forEach>
</table>
</div>
<br/><br/>
<table width="100%">
	<tr>
		<td align="center"><input type="button" value="선택" onclick="selectDong()" style="width:80px;height:30px;"/></td>
	</tr>
</table>
</c:if>

<c:if test="${fn:length(zipList) <= 0 }">
<div style="width:100%;height:50px;text-align:center;padding-top:25px;">
	검색 결과가 없습니다.
</div>
</c:if>

</body>
</html>